package demo.practice.binary_tree;

import demo.practice.TreeNode;

public class Offer28 {

    public boolean isSymmetric(TreeNode root) {

        //    1
        //   / \
        //  2   2
        // / \ / \
        //3  4 4  3
    //  2           2




        //L.left = R.right
        //L.right = R.left

        if(root==null)
            return true;

        return isSymmetric(root.left,root.right);


    }

    public boolean isSymmetric(TreeNode L,TreeNode R){
        if(L==null && R==null)
            return true;

        if(L==null|| R==null || L.val!=R.val)
            return false;

        return isSymmetric(L.left,R.right)&& isSymmetric(L.right,R.left);
    }



}
